package com.project.fiveCerealsSavoury.dao;


import java.sql.Timestamp;
import java.util.List;

import com.project.fiveCerealsSavoury.domain.Order;
import com.project.fiveCerealsSavoury.domain.OrderState;
import com.project.fiveCerealsSavoury.exception.BizException;
import com.project.fiveCerealsSavoury.transfer.AddOrder;

public interface OrderDao {
	/**
	 * 生成订单
	 * @param order
	 * @return
	 */
	public void addOrder(Order order);
	
	/**
	 * 查询指定状态的订单
	 * @param userId
	 * @param orderstate
	 * @return
	 */
	public List<Order> queryStateOrder(Integer userId, OrderState orderState);
	
	/**
	 * 修改订单状态
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public void modifyOrderState(String orderNumber, OrderState orderState);
	
	/**
	 * 删除订单
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public boolean removeOrder(String orderNumber, OrderState orderState);
	
	/**
	 * 查询所有订单
	 * @param orderNumber
	 * @return
	 */
	public Order queryAll(String orderNumber);
	
	/**
	 * 计数
	 * @return
	 */
	public int count();
	
	/**
	 * 分页查询所有订单
	 * @param pageSize
	 * @return
	 */
	public List<Order> queryList(OrderState status);
	
	/**
	 * 根据id 状态查询
	 * @param id
	 * @param orderState
	 * @return
	 */
	public Order queryById(Integer id, OrderState orderState);

	
	/**
	 * 根据订单状态查询所有用户的订单
	 * @param orderState
	 * @return
	 */
	public List<Order> queryOrder(OrderState orderState);

	
	/**
	 * 查询所有已支付订单数量
	 * @return
	 */
	public int counts();

	/**
	 * 添加到购物车
	 * @param order
	 * @return 
	 */
	public Integer addToCar(Order order);
	
	/**
	 * 根据商品名称和状态查询订单
	 * @param goodName
	 * @param orderState
	 * @return
	 */
	public Order queryCar(Integer userId,String goodName,OrderState orderState);
	
	/**
	 * 根据订单id修改商品数量
	 * @param id
	 * @return
	 */
	public boolean modifyNumber(Integer id,Integer newNumber);
	
	/**
	 * 根据订单id和订单状态删除购物车的商品
	 * @param id
	 * @param orderState
	 * @return
	 */
	public boolean removeCar(Integer id,OrderState orderState);
	
	/**
	 * 根据订单编号查询id
	 * @param orderState
	 * @return
	 * @throws BizException
	 */
	public Order queryByOrderState(String orderNumber);
	
	/**
	 * 修改订单状态和时间
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public void modifyDele(String orderNumber, OrderState orderState,Timestamp orderTime);
}
